﻿@model HelperMethods.Models.Person
@{
    ViewBag.Title = "CreatePerson";
    Html.EnableClientValidation(false); //we don't want validation attributes to be drawn
}
@*
Notice that we have set the name attribute on all of the input elements so that it corresponds to the model
property that the input element displays.
*@



<h2>CreatePerson</h2>
@using (Html.BeginForm())
{
    <div class="dataElem">
        <label>PersonId</label>
        @Html.TextBox("PersonId") @*option 1: search first viewbag then model*@
        @*
If we specify a string like DataValue.First.Name, the search becomes more complicated. The MVC
Framework will try different arrangements of the dot-separated elements, such as the following:
• ViewBag.DataValue.First.Name
• ViewBag.DataValue["First"].Name
• ViewBag.DataValue["First.Name"]
• ViewBag.DataValue["First"]["Name"]
        *@
    </div>
    <div class="dataElem">
        <label>First Name</label>
        @Html.TextBox("firstName", @Model.FirstName)  @*Option 2: give name and pass model*@
    </div>
    <div class="dataElem">
        <label>Last Name</label>
        @Html.TextBoxFor(m => m.LastName) @*Option 3: use lambda*@
    </div>
    <div class="dataElem">
        <label>Role</label>
        @Html.DropDownListFor(m => m.Role, new SelectList(Enum.GetNames(typeof(HelperMethods.Models.Role))))
    </div>
    <input type="submit" value="Submit" />
}



@*
Escribiendo html plano

<h2>CreatePerson</h2>
<form action="/Home/CreatePerson" method="post">
    <div class="dataElem">
        <label>PersonId</label>
        <input name="personId" value="@Model.PersonId"/>
    </div>
    <div class="dataElem">
        <label>First Name</label>
        <input name="FirstName" value="@Model.FirstName"/>
    </div>
    <div class="dataElem">
        <label>Last Name</label>
        <input name="lastName" value="@Model.LastName"/>
    </div>
    <input type="submit" value="Submit" />
</form>

*@
